//
//  AXFWhiteNavView.m
//  BEEQUICK
//
//  Created by HH on 16/11/24.
//  Copyright © 2016年 SevenGroup. All rights reserved.
//

#import "AXFWhiteNavView.h"

@interface AXFWhiteNavView ()

@property (nonatomic,weak)UILabel *nameLabel;
@property (nonatomic,weak)UIButton *functionBtn;

@end

@implementation AXFWhiteNavView

- (void)setupUI
{
    self.backgroundColor = [UIColor cz_colorWithHex:0xFAF9F6];
	
    UIButton *arrowBtn = [[UIButton alloc] init];
    
    [arrowBtn setImage:[UIImage imageNamed:@"v2_goback"] forState:UIControlStateNormal];
    
    [arrowBtn addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
    
    [self addSubview:arrowBtn];
    
    UILabel *nameLabel = [[UILabel alloc] init];
	
	self.nameLabel = nameLabel;
    
    self.nameLabel = nameLabel;
    
    nameLabel.text = @"结算付款";
    
    [self addSubview:nameLabel];
    
    UIButton *functionBtn = [[UIButton alloc] init];
	
	self.functionBtn = functionBtn;
    
    self.functionBtn = functionBtn;
    
    [functionBtn setTitle:@"客服电话" forState:UIControlStateNormal];
    
    functionBtn.titleLabel.font = [UIFont systemFontOfSize:12];
    
    [functionBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    
    [self addSubview:functionBtn];
    
    UIView *lineView = [[UIView alloc] init];
    
    lineView.backgroundColor = [UIColor grayColor];
    
    [self addSubview:lineView];
    
    [arrowBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self).offset(10);
        make.left.offset(8);
    }];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
		make.centerY.equalTo(arrowBtn);
    }];
    
    [functionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-8);
        make.centerY.equalTo(arrowBtn);
    }];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.width.equalTo(self);
        make.bottom.equalTo(self);
    }];
}

- (void)clickBtn:(UIButton *)sender
{
    if ([_delegate respondsToSelector:@selector(backToViewController)]) {
        [_delegate backToViewController];
    }
}

- (void)setTitleName:(NSString *)titleName andFunctionName:(NSString *)functionName
{
    self.nameLabel.text = titleName;
    
    [self.functionBtn setTitle:functionName forState:UIControlStateNormal];
}

@end
